<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>ImageFlow 0.9 and Spreadshop Web Services</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta name="language" content="en" />
<meta name="description" content=""/>
<meta name="keywords" content="ImageFlow, image flow, CoverFlow, cover flow, Javascript, imageflow in javascript, coverflow in javascript" />
<link rel="shortcut icon" href="" type="image/ico" />
<link rel="stylesheet" title="Standard" href="screen.css" type="text/css" media="screen" />
<link rel="stylesheet" href="screen.css" type="text/css" />
<script language="JavaScript" type="text/javascript" src="imageflow.js"></script><!-- -->
</head>
<body>

	<h1>Spreadshirt Web Services and ImageFlow 0.9</h1>
   <?php
    //error_reporting(E_ALL);
    $client = new SoapClient("http://www.spreadshirt.net/services.php?wsdl");
    $shopId = 281434;
    $token = $client->initialize_session($shopId);
    $token = $client->update_session($token, 'en','DE');
    $articles = $client->get_articles($token, $shopId);
    
    function LoadJpeg($imgname){
    $im = @imagecreatefrompng($imgname); /* Attempt to open */
      if (!$im) { /* See if it failed */
        $im  = imagecreatetruecolor(150, 30); /* Create a black image */
        $bgc = imagecolorallocate($im, 255, 255, 255);
        $tc  = imagecolorallocate($im, 0, 0, 0);
        imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
        /* Output an errmsg */
        imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
      }
      return $im;
    }
    
    $local_img_urls = array();
    foreach($articles as $article){
      $img_name = "img/" . $article->article_id . ".jpg";
      $local_img_paths[] = array('img_name'=>$img_name, 'name'=>$article->name, 'article_id'=>$article->article_id);
      $article->image_url = str_replace("http://www.spreadshirt.net/", "",$article->image_url);
      $article->image_url = str_replace("big", "huge",$article->image_url);
      $img = LoadJpeg($article->image_url);
      imagejpeg($img, $img_name);
    }
      
   ?>
<div id="imageflow"> 
	<div id="loading">
		<b>Loading images</b><br/>
		<img src="loading.gif" width="208" height="13" alt="loading" />
	</div>
	<div id="images">
  <?php
    
    foreach($local_img_paths as $local_img_path){
      $pathToShop = "http://$shopId.spreadshirt.net/en/DE/Shop/Article/Index/article/" . $local_img_path['article_id'];
      echo "\n" . '<img src="reflect.php?bgc=ffffff&img='. $local_img_path['img_name'] . '" longdesc="'. $pathToShop . '" alt="'. $local_img_path['name'] . '" />';
    }
    echo "\n";
?>
	</div>
	<div id="captions"></div>
	<div id="scrollbar">
		<div id="slider"></div>
	</div>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-514045-6");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>